<?php
	// Load the Qcodo Development Framework
	require('../includes/prepend.inc.php');

	/**
	 * This is a quick-and-dirty draft QForm object to do the List All functionality
	 * of the Transaction class.  It uses the code-generated
	 * TransactionDataGrid control which has meta-methods to help with
	 * easily creating/defining Transaction columns.
	 *
	 * Any display customizations and presentation-tier logic can be implemented
	 * here by overriding existing or implementing new methods, properties and variables.
	 * 
	 * NOTE: This file is overwritten on any code regenerations.  If you want to make
	 * permanent changes, it is STRONGLY RECOMMENDED to move both transaction_list.php AND
	 * transaction_list.tpl.php out of this Form Drafts directory.
	 *
	 * @package My Application
	 * @subpackage Drafts
	 */
	class TransactionListForm extends QForm {
		// Local instance of the Meta DataGrid to list Transactions
		protected $dtgBankRequestIns;
		protected $dtgBankRequestOuts;
		protected $dtgPaypalRequestIns;
		protected $dtgPaypalRequestOuts;
		protected $dtgEscrowsIn;
		protected $dtgEscrowsOut;
		protected $dtgTransactions;
		
		

		// Create QForm Event Handlers as Needed

//		protected function Form_Exit() {}
//		protected function Form_Load() {}
//		protected function Form_PreRender() {}
//		protected function Form_Validate() {}

		protected function Form_Run() {
			// Security check for ALLOW_REMOTE_ADMIN
			// To allow access REGARDLESS of ALLOW_REMOTE_ADMIN, simply remove the line below
			QApplication::CheckRemoteAdmin();
		}

		protected function Form_Create() {
			// Instantiate the Meta DataGrid
			$this->dtgBankRequestIns = new BankRequestInDataGrid($this);
			$this->dtgBankRequestOuts = new BankRequestOutDataGrid($this);
			$this->dtgPaypalRequestIns = new PaypalRequestInDataGrid($this);
			$this->dtgPaypalRequestOuts = new PaypalRequestOutDataGrid($this);
			$this->dtgEscrowsIn = new EscrowDataGrid($this);
			$this->dtgEscrowsOut = new EscrowDataGrid($this);
			$this->dtgTransactions = new TransactionDataGrid($this);

			// Style the DataGrid (if desired)
			//Bank Request In
			$this->dtgBankRequestIns->CssClass = 'datagrid';
			$this->dtgBankRequestIns->AlternateRowStyle->CssClass = 'alternate';
			// Bank Request Out
			$this->dtgBankRequestOuts->CssClass = 'datagrid';
			$this->dtgBankRequestOuts->AlternateRowStyle->CssClass = 'alternate';
			//Paypal Request In
			$this->dtgPaypalRequestIns->CssClass = 'datagrid';
			$this->dtgPaypalRequestIns->AlternateRowStyle->CssClass = 'alternate';
			//Paypal Request Out
			$this->dtgPaypalRequestOuts->CssClass = 'datagrid';
			$this->dtgPaypalRequestOuts->AlternateRowStyle->CssClass = 'alternate';
			//Escorw In
			$this->dtgEscrowsIn->CssClass = 'datagrid';
			$this->dtgEscrowsIn->AlternateRowStyle->CssClass = 'alternate';
			//Escorw Out
			$this->dtgEscrowsOut->CssClass = 'datagrid';
			$this->dtgEscrowsOut->AlternateRowStyle->CssClass = 'alternate';
			
			//All Transaction
			$this->dtgTransactions->CssClass = 'datagrid';
			$this->dtgTransactions->AlternateRowStyle->CssClass = 'alternate';

			// Add Pagination (if desired)
			//Bank Request In
			//$this->dtgBankRequestIns->Paginator = new QPaginator($this->dtgBankRequestIns);
			//$this->dtgBankRequestIns->ItemsPerPage = 20;
				// Bank Request Out
			//$this->dtgBankRequestOuts->Paginator = new QPaginator($this->dtgBankRequestOuts);
			//$this->dtgBankRequestOuts->ItemsPerPage = 20;
			//Paypal Request In
			//$this->dtgPaypalRequestIns->Paginator = new QPaginator($this->dtgPaypalRequestIns);
			//$this->dtgPaypalRequestIns->ItemsPerPage = 20;
			//Paypal Request Out
			//$this->dtgPaypalRequestOuts->Paginator = new QPaginator($this->dtgPaypalRequestOuts);
			//$this->dtgPaypalRequestOuts->ItemsPerPage = 20;
			//Escorw In
			//$this->dtgEscrowsIn->Paginator = new QPaginator($this->dtgEscrowsIn);
			//$this->dtgEscrowsIn->ItemsPerPage = 20;
			//Escorw Out
			//$this->dtgEscrowsOut->Paginator = new QPaginator($this->dtgEscrowsIn);
			//$this->dtgEscrowsOut->ItemsPerPage = 20;
			//All Transaction
			//$this->dtgTransactions->Paginator = new QPaginator($this->dtgTransactions);
			//$this->dtgTransactions->ItemsPerPage = 20;

			// Use the MetaDataGrid functionality to add Columns for this datagrid

			// Create an Edit Column
			//Bank Request In
			//$strEditPageUrl = __VIRTUAL_DIRECTORY__ . __FORM_DRAFTS__ . '/bank_request_in_edit.php';
			//$this->dtgBankRequestIns->MetaAddEditLinkColumn($strEditPageUrl, 'Edit', 'Edit');
			// Bank Request Out
			//$strEditPageUrl = __VIRTUAL_DIRECTORY__ . __FORM_DRAFTS__ . '/bank_request_out_edit.php';
			//$this->dtgBankRequestOuts->MetaAddEditLinkColumn($strEditPageUrl, 'Edit', 'Edit');
			//Paypal Request In
			//$strEditPageUrl = __VIRTUAL_DIRECTORY__ . __FORM_DRAFTS__ . '/paypal_request_in_edit.php';
			//$this->dtgPaypalRequestIns->MetaAddEditLinkColumn($strEditPageUrl, 'Edit', 'Edit');
			//Paypal Request Out
			//$strEditPageUrl = __VIRTUAL_DIRECTORY__ . __FORM_DRAFTS__ . '/paypal_request_out_edit.php';
			//$this->dtgPaypalRequestOuts->MetaAddEditLinkColumn($strEditPageUrl, 'Edit', 'Edit');
			//Escorw In
			//$strEditPageUrl = __VIRTUAL_DIRECTORY__ . __FORM_DRAFTS__ . '/escrow_edit.php';
			//$this->dtgEscrowsIn->MetaAddEditLinkColumn($strEditPageUrl, 'Edit', 'Edit');
			//Escorw Out
			//$strEditPageUrl = __VIRTUAL_DIRECTORY__ . __FORM_DRAFTS__ . '/escrow_edit.php';
			//$this->dtgEscrowsOut->MetaAddEditLinkColumn($strEditPageUrl, 'Edit', 'Edit');
			
			//All Transaction
			//$strEditPageUrl = __VIRTUAL_DIRECTORY__ . __FORM_DRAFTS__ . '/transaction_edit.php';
			//$this->dtgTransactions->MetaAddEditLinkColumn($strEditPageUrl, '', '');

			// Create the Other Columns (note that you can use strings for transaction's properties, or you
			// can traverse down QQN::transaction() to display fields that are down the hierarchy)
		
			// Bank Request In
			
			$this->dtgBankRequestIns->MetaAddColumn(QQN::BankRequestIn()->User);
			$this->dtgBankRequestIns->MetaAddColumn('Amount');
			$this->dtgBankRequestIns->MetaAddColumn('FeeTaken');
			$this->dtgBankRequestIns->MetaAddColumn('RequestDate');
			$this->dtgBankRequestIns->MetaAddColumn('ActualAmount');
			$this->dtgBankRequestIns->MetaAddColumn('ActualFeeTaken');
			$this->dtgBankRequestIns->MetaAddColumn(QQN::BankRequestIn()->BankDeposit);
			$this->dtgBankRequestIns->AddColumn(new QDataGridColumn('status', '<img src="<?=__IMAGE_ASSETS__?>/tick.png"/>',
				// And we make sure to set HtmlEntities to "false" so that our checkbox doesn't get HTML Escaped
				'HtmlEntities=false'
			));
			
			
			//Bank Request Out
			
			$this->dtgBankRequestOuts->MetaAddColumn(QQN::BankRequestOut()->User);
			$this->dtgBankRequestOuts->MetaAddColumn('Amount');
			$this->dtgBankRequestOuts->MetaAddColumn('FeeTaken');
			$this->dtgBankRequestOuts->MetaAddColumn('RequestDate');
			$this->dtgBankRequestOuts->MetaAddColumn('ActualAmount');
			$this->dtgBankRequestOuts->MetaAddColumn('ActualFeeTaken');
			$this->dtgBankRequestOuts->MetaAddColumn(QQN::BankRequestOut()->BankWithdraw);
			
			//Paypal Request In
			$this->dtgPaypalRequestIns->MetaAddColumn(QQN::PaypalRequestIn()->User);
			$this->dtgPaypalRequestIns->MetaAddColumn('AmountWithdrawFromProaucSite');
			$this->dtgPaypalRequestIns->MetaAddColumn('FeePaypal');
			$this->dtgPaypalRequestIns->MetaAddColumn('PaypalEmail');
			$this->dtgPaypalRequestIns->MetaAddColumn('RequestDate');
			$this->dtgPaypalRequestIns->MetaAddColumn('Amount');
			$this->dtgPaypalRequestIns->MetaAddColumn('ReturnedAmount');
			
			//Paypal Request Out
			$this->dtgPaypalRequestOuts->MetaAddColumn(QQN::PaypalRequestOut()->User);
			$this->dtgPaypalRequestOuts->MetaAddColumn('FeePaypal');
			$this->dtgPaypalRequestOuts->MetaAddColumn('PaypalEmail');
			$this->dtgPaypalRequestOuts->MetaAddColumn('RequestDate');
			$this->dtgPaypalRequestOuts->MetaAddColumn('Amount');
			$this->dtgPaypalRequestOuts->MetaAddColumn('ReturnedAmount');
			
			//Escorw In
			//$this->dtgEscrowsIn->MetaAddColumn(QQN::Escrow()->UserIdFromObject);
			$this->dtgEscrowsIn->MetaAddColumn(QQN::Escrow()->UserIdToObject);
			$this->dtgEscrowsIn->MetaAddColumn(QQN::Escrow()->Project);
			$this->dtgEscrowsIn->MetaAddColumn('Amount');
			$this->dtgEscrowsIn->MetaAddColumn('Reason');
			$this->dtgEscrowsIn->MetaAddColumn('EscrowDate');
			$this->dtgEscrowsIn->MetaAddColumn('PaidDate');
			//$this->dtgEscrowsIn->MetaAddColumn(QQN::Escrow()->Transaction);
			
			//Escorw In
			$this->dtgEscrowsOut->MetaAddColumn(QQN::Escrow()->UserIdFromObject);
			//$this->dtgEscrowsOut->MetaAddColumn(QQN::Escrow()->UserIdToObject);
			$this->dtgEscrowsOut->MetaAddColumn(QQN::Escrow()->Project);
			$this->dtgEscrowsOut->MetaAddColumn('Amount');
			$this->dtgEscrowsOut->MetaAddColumn('Reason');
			$this->dtgEscrowsOut->MetaAddColumn('EscrowDate');
			$this->dtgEscrowsOut->MetaAddColumn('PaidDate');
			//$this->dtgEscrowsOut->MetaAddColumn(QQN::Escrow()->Transaction);
			
			//All Transaction
			$this->dtgTransactions->MetaAddColumn(QQN::Transaction()->User);
			$this->dtgTransactions->MetaAddColumn(QQN::Transaction()->Project);
			$this->dtgTransactions->MetaAddColumn('BalanceBefore');
			$this->dtgTransactions->MetaAddColumn('BalanceAfter');
			$this->dtgTransactions->MetaAddColumn('Amount');
			$this->dtgTransactions->MetaAddColumn('TransactionDate');
			$this->dtgTransactions->MetaAddColumn('Description');
			$this->dtgTransactions->MetaAddTypeColumn('TransactionType', 'TransactionType');
		}
		
	}

	// Go ahead and run this form object to generate the page and event handlers, implicitly using
	// transaction_list.tpl.php as the included HTML template file
	TransactionListForm::Run('TransactionListForm');
?>